<?php

class Application_Model_PriceSystemsService
extends Application_Model_BaseService
{
    protected $dbTableName = 'Application_Model_DbTable_PriceSystems';
    protected $modelName = 'Application_Model_PriceSystem';
	private   static $instance = null;
    
    public static function getInstance(){
        if (Application_Model_PriceSystemsService::$instance == null)
            Application_Model_PriceSystemsService::$instance = 
                new Application_Model_PriceSystemsService();
        
        return Application_Model_PriceSystemsService::$instance;
    }
    
    public function getPaginatorRows ($pageNumber = 1)
	{
		$paginator = new Zend_Paginator(
            new Zend_Paginator_Adapter_DbSelect(
                $this   ->getDbTable()
                        ->select()                     
            )
        );
        
		$paginator->setCurrentPageNumber($pageNumber);
		$paginator->setItemCountPerPage(6);
		$paginator->setPageRange(3);
		return $paginator;
	}
    
    public function findById($id){
    	$result = $this->getDbTable()->find($id);
    	if (count($result) == 1) {
            $rows = $result->current();
            $obj = $this->mapToObject($rows);
        }
        return $obj;
    }
}

